<?php
defined('SECRET_KEY') or define('SECRET_KEY','sdRsw4&2iBY4cr');
defined('COOKIE_KEY') or define('COOKIE_KEY','_i');
defined('USER_MEM_KEY') or define('USER_MEM_KEY','member_info_');
defined('USER_CNT_KEY') or define('USER_CNT_KEY','member_cnt_');
defined('MEMBER_MALE') or define('MEMBER_MALE',1);
defined('MEMBER_FEMALE') or define('MEMBER_FEMALE',2);
defined('EXPIRE_PWD') or define('EXPIRE_PWD',3600*24);
 
class ConstMembers{
	/**
	 * 用户状态
	 */
	const FLAG_NOT_ACTIVE	=	0;
	const FLAG_NORMAL		=	1;	//普通用户
	const FLAG_CARTOONISTS	=	2;	//漫画家
	const FLAG_ADMIN		=	3;	//管理员
	const FLAG_SHIELDING	=	9;	//屏蔽用户
	
	/**
	 * 错误代码
	 */
	const  ERR_LOGIN_NO_UID		=	-1;	//没有登录
	const  ERR_EXIST_USER		=	-2;	//用户名存在
	const  ERR_EXIST_EMAL		=	-3;	//邮箱已经存在
	const  ERR_INVALID_USER		=	-4;	//用户名错误
	const  ERR_INVALID_PWD		=	-5;	//用户名错误
	const  ERR_NOT_ACTIVE		=	-5;	//用户未激活
}


$_SERVER['config']['user'] = array(
	ConstMembers::FLAG_NOT_ACTIVE	=>' 未激活',
	ConstMembers::FLAG_NORMAL =>'普通用户',
	ConstMembers::FLAG_CARTOONISTS =>'作者',
	ConstMembers::FLAG_ADMIN	=> '管理员',
	ConstMembers::FLAG_SHIELDING =>'屏蔽'
);

$_SERVER['const']['marriage'] = array(
	1=>'单身',
	2=>'恋爱中',
	3=>'已婚'
);

$_SERVER['const']['bloodtype'] = array(
	0=>'未知',
	1=>'A型',
	2=>'B型',
	3=>'O型',
	4=>'AB行'
);

$_SERVER['const']['mail']	=	array(
	'host'		=>	'smtp.163.com',
	'port'		=>	'25',
	'username'	=>	'fanzhanao@163.com',
	'pwd'		=>	'111111'
);

/**
 * 生成key
 *
 * @return unknown
 */
function genKey(){
	$arg_num = func_num_args();//获取参数个数
	if($arg_num>0){
		$arg_list = func_get_args();
		array_push($arg_list,SECRET_KEY);
		$arg_list	=	func_get_args();
		$arg_list = implode('|',$arg_list);
		return md5($arg_list);
	}
	return false;
}

/**
 * 去空格
 * @param unknown_type $str
 */
function trim_str($str){
	return preg_replace("/[\s]+/"," ", $str);
}
/**
 * 获取随机码
 * @param int $len  获取随机码的长度
 * @return string
 */
function getRandom($len = 16){
	return substr(md5(uniqid(rand(), true)),0,$len);
}

/**
 * 检查email格式
 * @param string $email
 * @return boolean
 */
function checkEmail($email){
	$pattern="/^([\w\.-]+)@([a-zA-Z0-9-]+)(\.[a-zA-Z\.]+)$/i";
	return preg_match($pattern,$email);
}

?>